package model.filter
{
	import model.registry.ErrorMessage;

	/**
	 * 数组有效值过滤
	 **/
	public class MapFilter
	{
		public function MapFilter()
		{
		}
		
		/**
		 * 判断经纬度同时为零的去掉
		 **/
		public static function updateArray(list:Array):Array
		{
			var outList:Array = new Array();
			for each(var item:Object in list)
			{
				if(item != null && item.latitude != "" && item.longitude)
				{
					outList.push(item);
				}
			}
			return outList;
		}
		
		/**
		 * 更新整个地图数据
		 **/
		public static function updateTotalMap(mapData:Object):Object
		{
			var newOutMapData:Object = new Object();
			if(mapData != null 
				&& mapData.sat != null 
				&& mapData.map != null)
			{
				newOutMapData.sat = updateArray(mapData.sat);
				newOutMapData.map = updateArray(mapData.map); 
			}
			else
			{
				throw new Error(ErrorMessage.BAD_CONTEXT);
			}
			return newOutMapData;
		}
	}
}